package com.week2.day01;

public class Warrior extends Hero {             //Hero类下的战士子类
    private int rage;                           //怒气值

    public Warrior() {                          //空参构造，默认怒气20
        super();
        this.rage = 20;
    }

    public Warrior(String name) {               //单参构造，只有名字。怒气默认20
        super(name);
        this.rage = 20;
    }

    public Warrior(String name, int power, int agile, int intelligence, int rage) {         //全参构造，共5个参数
        super(name, power, agile, intelligence);
        if (rage <= 100 && rage >= 0) {
            this.rage = rage;
        } else {
            this.rage = 20;
        }
    }

    //get and set 方法
    public int getRage() {
        return rage;
    }

    public void setRage(int rage) {
        this.rage = rage;
    }

    public void heroicStrike() {                    //英勇打击
        if (rage >= 20) {                               //判断怒气是否足够20
            int heroicStrikeDamage = normalAttack() * 2;        //计算本次英勇打击伤害
            setRage(this.rage - 20);                            //怒气值-20
            System.out.println("英勇打击伤害：" + heroicStrikeDamage + ",当前怒气值：" + getRage());
        } else {
            System.out.println("怒气不足，无法施放");
        }
    }

    public void injured() {                     //收到伤害时，触发效果
        if (rage <= 90) {                           //判断怒气是否超过90,怒气最大值100
            setRage(this.rage + 10);            //怒气+10
            System.out.println("受到伤害，怒气加10，当前怒气：" + getRage());
        } else {
            System.out.println("怒气已满");
        }
    }

    @Override
    public String toString() {
        return super.toString() +"\n"+
                "战士特有{" +
                "怒气=" + rage +
                "} ";
    }
}
